<?php if(!defined('SABLOG_ROOT')) exit('Access Denied');?>
<div id="submenu">
	<ul>
		<!--{if $sax_group == 1}-->
			<li><a href="cp.php?job=user&action=list" <!--{if $action == 'list'}--> class="focus"<!--{/if}-->><span>用户列表</span></a></li>
			<li><a href="cp.php?job=user&action=add" <!--{if $action == 'add'}--> class="focus"<!--{/if}-->><span>添加用户</a></li>
			<!--{if $action == 'mod'}-->
				<li><a href="###" class="focus"><span>编辑用户</span></a></li>
			<!--{/if}-->
		<!--{/if}-->
		<li><a href="cp.php?job=user&action=profile" <!--{if $action == 'profile'}--> class="focus"<!--{/if}-->><span>修改个人信息</a></li>
	</ul>
</div>

<div id="wrap">
<h2>{$subnav}&raquo;</h2>

<!--{if $action == 'list'}-->
	<table border="0" cellspacing="0" cellpadding="0">
		<form method="post" action="cp.php?job=user&action=list">
		<tr class="tablecell2">
			<td>组别:<br />
				<select name="groupid">
					<option value="">== 全部 ==</option>
					<option value="1" <!--{if $groupid == 1}-->selected<!--{/if}-->>管理组</option>
					<option value="2" <!--{if $groupid == 2}-->selected<!--{/if}-->>撰写组</option>
					<option value="3" <!--{if $groupid == 3}-->selected<!--{/if}-->>注册组</option>
				</select>
			</td>
			<td>排列依据:<br />
				<select name="field">
					<option value="userid" <!--{if $field == 'userid'}-->selected<!--{/if}-->>== 默认 ==</option>
					<option value="username" <!--{if $field == 'username'}-->selected<!--{/if}-->>用户名</option>
					<option value="logincount" <!--{if $field == 'logincount'}-->selected<!--{/if}-->>登陆次数</option>
					<option value="regdateline" <!--{if $field == 'regdateline'}-->selected<!--{/if}-->>注册时间</option>
					<option value="lastpost" <!--{if $field == 'lastpost'}-->selected<!--{/if}-->>最后评论时间</option>
				</select>
			</td>
			<td>顺序:<br />
				<select name="order">
					<option value="desc" <!--{if $order == 'desc'}-->selected<!--{/if}-->>降序</option>
					<option value="asc" <!--{if $order == 'asc'}-->selected<!--{/if}-->>升序</option>
				</select>
			</td>
			<td>关键字:<br />
				<input class="formfield" type="text" name="srhname" size="20" maxlength="30" value="$srhname" />
			</td>
			<td colspan="2" align="center" class="tablecell">
				<input type="hidden" name="action" value="list" />
				<button type="submit">过滤</button>
			</td>
		</tr>
		</form>
	</table>
<!--{/if}-->

<form action="cp.php?job=user" method="POST">
<!--{if $action == 'list'}-->
	<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr class="tdbheader">
			<td nowrap>用户名</td>
			<td nowrap>用户组</td>
			<td nowrap>联系方式</td>
			<td nowrap>注册时间</td>
			<td nowrap>最近访问时间</td>
			<td width="5%" nowrap><input name="chkall" value="on" type="checkbox" onclick="checkall(this.form)" /></td>
		</tr>
		<!--{loop $userdb $user}-->
			<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
			<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
				<td nowrap><a href="cp.php?job=user&action=mod&userid=$user[userid]">$user[username]</a></td>
				<td>$user[group]</td>
				<td>				
					<!--{if $user['email']}-->
						<a href="mailto:{$user[email]}" target="_blank">$user[email]</a>
					<!--{else}-->
						<font color="#FF0000">Null</font>
					<!--{/if}-->

					<!--{if $user['url']}-->
						<a href="$user[url]" target="_blank"><img src="./templates/admin/images/homelink.gif" border="0" alt="访问该用户的网站" class="attach" /></a>
					<!--{/if}-->
				</td>
				<td>$user[regdateline]</td>
				<td>$user[lastvisit]</td>
				<td><input type="checkbox" name="user[]" value="$user[userid]" $user[disabled] /></td>
			</tr>
		<!--{/loop}-->
		<tr class="tablecell">
			<td colspan="9" nowrap="nowrap"><div class="records">记录:$total</div>
		  <div class="multipage">$multipage</div></td>
		</tr>
	</table>
	<div class="submit">
		<input type="hidden" name="action" value="del" />
		<button type="submit">删除所选用户</button>
	</div>
<!--{elseif in_array($action, array('add', 'mod', 'profile'))}-->

	<!--{if in_array($action, array('add', 'mod'))}-->
	<div class="input">
		<h2>登陆名</h2>
		<p>
			<input class="formfield" type="text" name="username" size="50" value="$info[username]" />
		</p>
	</div>
	<!--{/if}-->
	<!--{if $action == 'profile'}-->
	<div class="input">
		<h2>旧密码</h2>
		<p>
			<input class="formfield" type="password" name="old_password" size="50" value="" /><br />
			<span class="describe">修改密码时需要输入旧密码.</span>
		</p>
	</div>
	<!--{/if}-->
	<div class="input">
		<h2>新密码</h2>
		<p>
			<input class="formfield" type="password" name="newpassword" size="50" value="" /><br />
			<span class="describe">不改请留空, 密码不能少于8个字符.</span>
		</p>
	</div>
	<div class="input">
		<h2>确认新密码</h2>
		<p>
			<input class="formfield" type="password" name="confirmpassword" size="50" value="" /><br />
			<span class="describe">请再输入一次密码.</span>
		</p>
	</div>
	<!--{if in_array($action, array('add', 'mod'))}-->
	<div class="input">
		<h2>用户组</h2>
		<p>
			<select name="groupid">
				<option value="1" $groupselect[1]>管理员</option>
				<option value="2" $groupselect[2]>撰写组</option>
				<option value="3" $groupselect[3]>注册组</option>
			</select>
		</p>
	</div>
	<!--{/if}-->
	<div class="input">
		<h2>E-mail</h2>
		<p>
			<input class="formfield" type="text" name="email" size="50" value="$info[email]" />
		</p>
	</div>
	<div class="input">
		<h2>主页</h2>
		<p>
			<input class="formfield" type="text" name="url" size="50" value="$info[url]" />
		</p>
	</div>
	<div class="submit">
		<input type="hidden" name="action" value="$do" />
		<input type="hidden" name="userid" value="$info[userid]" />
		<button type="submit">确定</button>
	</div>
	<!--{if in_array($action, array('mod', 'profile'))}-->
		<div class="clear"></div>
		<h2>访问信息&raquo;</h2>
		<ul class="info">
			<li><u>注册时间:</u>$info[regdateline]</li>
			<li><u>注册IP:</u>$info[regip]</li>
			<li><u>最后评论时间:</u>$info[lastpost]</li>
			<li><u>最后访问IP:</u>$info[lastip]</li>
			<li><u>最后访问时间:</u>$info[lastvisit]</li>
			<li><u>最后活动时间:</u>$info[lastactivity]</li>
		</ul>
	<!--{/if}-->
<!--{elseif $action == 'del'}-->
	<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr class="alertheader">
			<td><a name="删除用户"></a>删除用户</td>
		</tr>
		<tr>
			<td class="alertbox">
			<p><b>注意:<br />UserID为1的用户和管理员不能删除,要删除其他管理员请先把用户组改成其他组.<br />删除用户并不会删除用户发表过的评论.</b></p>
			<p><ol>
			<!--{loop $userdb $user}-->
			<li><a href="cp.php?job=user&action=mod&userid=$user[userid]">$user[username]</a><input type="hidden" name="user[]" value="$user[userid]" /></li>
			<!--{/loop}-->
			</ol></p>
			<p><b>你确实要删除以上用户吗? 此操作一旦执行, 将无法撤销!</b></p>
			<p>如果有撰写组的用户,删除其所发表的文章:<br /><select name="deluserarticle">
			<option value="1">是</option>
			<option value="0" selected>否</option>
			</select></p>
			<p><button type="submit">确定</button></p>
			<input type="hidden" name="action" value="delusers" />
			</td>
		</tr>
	</table>
<!--{/if}-->
</form>